<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

//Route::get('/', function () {
//    return view('welcome');
//});

Route::get('/test', [App\Http\Controllers\ExampleController::class, 'index']);

use App\Http\Controllers;
//home
Route::get('/', [Controllers\HomeController::class, 'index']);
Route::get('/search/', [Controllers\HomeController::class, 'search']);
Route::match(['get', 'post'],'/search/{keyboard}', [Controllers\HomeController::class, 'search']);
Route::get('/dates/', [Controllers\HomeController::class, 'dates']);
Route::get('/date/{keyboard}', [Controllers\HomeController::class, 'dates']);

//tag
Route::get('/tags/', [Controllers\TagController::class, 'tags']);
Route::get('/tag/{keyboard}.html', [Controllers\TagController::class, 'tags']);
//file
Route::get('/files/', [Controllers\FileController::class, 'files']);
Route::get('/file/{keyboard}.html', [Controllers\FileController::class, 'files']);
//art
Route::get('/detail/{keyboard}.html', [Controllers\ArtController::class, 'index']);
Route::post('/detail/comment', [Controllers\ArtController::class, 'comment'])->middleware('auth');
//Route::match(['get', 'post'],'/detail/comment', [Controllers\ArtController::class, 'comment'])->middleware('auth');

//user
Route::get('user', [Controllers\UserController::class, 'index'])->middleware('auth');
Route::get('login', [Controllers\UserController::class, 'login'])->name('login');//用->middleware('auth')需要定义name('login')不然报错：Route [login] not defined.
Route::post('login', [Controllers\UserController::class, 'login']);
Route::get('register', [Controllers\UserController::class, 'register']);
Route::post('register', [Controllers\UserController::class, 'register']);
Route::get('logout', [Controllers\UserController::class, 'logout']);

//sse chatgpt
Route::get('/chatgpt', [Controllers\SseController::class, 'index']);
Route::get('/chatgptsse', [Controllers\SseController::class, 'chatgptsse']);

//动态分类url为一级，避免冲突放所有固定一级url的后面
Route::get('/{keyboard}', [Controllers\HomeController::class, 'cates']);


//Laravel 5.5.10+,当没有其他路由与当前请求匹配时，跑这里，它可以自定义一个备选路由或者404
Route::fallback(function(){
    abort(404);
});
